<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>求一组数中的最大值和最小值，以及所在位置</title>
	</head>
	<body>
		<script>
			 var arr = [0, 5, -3, 6, 2, -6, 10];
          
         var maxValue = arr[0];
         var minValue = arr[0];
         var maxIndex = 0;
          var minIndex = 0;
          for (var i = 1; i < arr.length; i++) {
              if(arr[i] > maxValue){
                 
                 maxValue = arr[i];
                maxIndex = i;
             }
             
             if (arr[i] < minValue) {
                 minValue = arr[i];
                 minIndex = i;
             }
         }
         console.log(maxValue);
         console.log(maxIndex);
        console.log(minValue);
        console.log(minIndex);
		</script>
	</body>
</html>
